package com.cloud.config.amqp;

import com.cloud.config.SecurityCloudConfig;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class DirectRabbitConfig {
    @Autowired
    private SecurityCloudConfig securityCloudConfig;

    @Bean
    public Queue DirectFireQueue() {
        return new Queue(securityCloudConfig.getAlgorithmDetectFireQueueName(), true);
    }

    @Bean
    public Queue DirectFireDoorQueue() {
        return new Queue(securityCloudConfig.getAlgorithmDetectFireDoorQueueName(), true);
    }

    @Bean
    public Queue DirectFireExitsQueue() {
        return new Queue(securityCloudConfig.getAlgorithmDetectFireExitsQueueName(), true);
    }

    @Bean
    public Queue DirectFirePersonQueue() {
        return new Queue(securityCloudConfig.getAlgorithmDetectFirePersonQueueName(), true);
    }

    @Bean
    public Queue DirectFireDehazingQueue() {
        return new Queue(securityCloudConfig.getAlgorithmDetectFireDehazingQueueName(), true);
    }

    @Bean
    public DirectExchange DirectFireExchange() {
        return new DirectExchange(securityCloudConfig.getAlgorithmDetectFireExchangeName(), true, false);
    }

    @Bean
    public DirectExchange DirectFireDoorExchange() {
        return new DirectExchange(securityCloudConfig.getAlgorithmDetectFireDoorExchangeName(), true, false);
    }

    @Bean
    public DirectExchange DirectFireExitsExchange() {
        return new DirectExchange(securityCloudConfig.getAlgorithmDetectFireExitsExchangeName(), true, false);
    }

    @Bean
    public DirectExchange DirectFirePersonExchange() {
        return new DirectExchange(securityCloudConfig.getAlgorithmDetectFirePersonExchangeName(), true, false);
    }

    @Bean
    public DirectExchange DirectFireDehazingExchange() {
        return new DirectExchange(securityCloudConfig.getAlgorithmDetectFireDehazingExchangeName(), true, false);
    }

    @Bean
    Binding bindingFireDirect() {
        return BindingBuilder.bind(DirectFireQueue()).to(DirectFireExchange()).with("FireRouting");
    }

    @Bean
    Binding bindingFireDoorDirect() {
        return BindingBuilder.bind(DirectFireDoorQueue()).to(DirectFireDoorExchange()).with("FireDoorRouting");
    }

    @Bean
    Binding bindingFireExitsDirect() {
        return BindingBuilder.bind(DirectFireExitsQueue()).to(DirectFireExitsExchange()).with("FireExitsRouting");
    }

    @Bean
    Binding bindingFirePersonDirect() {
        return BindingBuilder.bind(DirectFirePersonQueue()).to(DirectFirePersonExchange()).with("FirePersonRouting");
    }

    @Bean
    Binding bindingFireDehazingDirect() {
        return BindingBuilder.bind(DirectFireDehazingQueue()).to(DirectFireDehazingExchange()).with("FireDehazingRouting");
    }
}
